<!DOCTYPE html>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="stylesheet" type="text/css" href="search_style.css">
<link rel="stylesheet" type="text/css" href="smooth_jquery-ui.css" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/> <!--320-->
<title>NoteItAll</title>

<script src="jquery/jquery-1.9.1.min.js"></script>

<script>

jQuery(function() {

function setHeight(group) {

    group.each(function() {
        var thisHeight = $(this).height();
		$(this).bind('click',function(event) {
				if($(this).height() == 45){
					$(this).animate({
						height: thisHeight+'px'
					}, 300);
				}
				else
				{
					$(this).animate({
					height: '45px'
					}, 300);
				}
			});
		$(this).height(45);
    });
    
}



$(document).ready(function() {
    setHeight($("#notes_list .text"));

    searchSub();

    $('#noteArea').each(function() {
    	   var elem = $(this);

    	   // Save current value of element
    	   elem.data('oldVal', elem.val());

    	   // Look for changes in the value
    	   elem.bind("propertychange keyup input paste", function(event){
    	      // If value has changed...
    	      if (elem.data('oldVal') != elem.val()) {
    	       // Updated stored value
    	       elem.data('oldVal', elem.val());

    	       // Do action
    	       searchSub();
    	     }
    	   });
    	 });
    
});


});

</script>

<!-- Added from here -->
<script src="jquery/jquery-1.9.1.min.js"></script>
<script src="jquery/jquery.caret.js"></script>
<script src="jquery/jquery.nia-ac.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
  <!-- Added end here -->
  
<?php 
$tid = $_GET["tid"]; 
?>

<script>
function formSubmit()
{
	alert("hi");
  //document.getElementById("note").submit();
}

function searchSub(){
	  //alert($("#noteArea").val());
	  $.post("searchHandle.php", 
		  	  {keyword:$("#noteArea").val()}, 
		  	  function(data){
	  		  	  //alert(data);
	  		  	  var html = "";
	  		 	  for (var key=0; key<data.id; key++)
	  		 	  {
	  		 		html = html+"<div class=\"text\">";
					if((data[key].html).indexOf("#") !== -1)
					{
						html = html+ "<div class=\"color\" id=\"green\"></div>";
					}
					if((data[key].html).indexOf("@") !== -1)
					{
						html = html+ "<div class=\"color\" id=\"red\"></div>";
					}
					if((data[key].html).indexOf("*") !== -1)
					{
						html = html+ "<div class=\"color\" id=\"coffee\"></div>";
					}
					if((data[key].html).indexOf("^") !== -1)
					{
						html = html+ "<div class=\"color\" id=\"blue\"></div>";
					}
					html = html+ "<a href=\"index.php?rid="+data[key].id+"\"><img src=\"./img/pencil.jpg\"></a>";
	  		 		html = html+data[key].html;
	  		 		html = html+"</div>";
	  		 	  }
	  		 	  $("#notes_list").html(html);
	  		 	  $("#record").text(data.id+" Records");
	  		  },
	  		  "json"
	  		);
	}

</script>

</head>

<body>

<div id="locationTabs">
<ul>
<li><a href="index.php"><img src="./img/new.png" /></a></li>
<li><div onclick="searchSub();"><img src="./img/browse.png" /></div></li>
<li><a href="calendar.php"><img src="./img/calendar_top.png" /></a></li>
</ul>
</div><!-- locationTabs -->


<div class="query">
			<div onclick="$().addTagType('noteArea', ' and ');">and</div>
			<div onclick="$().addTagType('noteArea', ' or ');">or</div>
			<div onclick="$().addTagType('noteArea', ' not ');">not</div>
</div>

<!-- Added code start here -->
<div id="noteBox">

	<form name="note" id="note" action="searchHandle.php" method="get">
		
		<input type="text" name="keyword" id="noteArea" value="<?php echo $tid; ?>"><br>
 		
 		<div class="buttons">
			<div onclick="$().addTagType('noteArea', '#');"><img src="./img/category.png" alt="catigorie"/></div>
			<div onclick="$().addTagType('noteArea', '@');"><img src="./img/calendar.png" alt="date"/></div>
			<div onclick="$().addTagType('noteArea', '*');"><img src="./img/check.png" alt="to-do"/></div>
			<div onclick="$().addTagType('noteArea', '^');"><img src="./img/contact.png" alt="contact"/></div>
		</div><!-- buttons -->
	</form>

</div><!-- noteBox -->
<!-- Added note ends here -->

<div id="record">0 Records</div>

<div id="invisible">
<div id="notes_list">

<?php
/*
$array = array("After a paramedic's radiation detector went off at the scene, investigators declared the area \"safe and clear to work in,\" the Thames Valley Police said in a statement Sunday.", 
"It's the ePad Femme -- an 8-inch tablet device designed specifically for women, and already preloaded with special female-friendly apps. As opposed to, say, Angry Birds which, apparently, requires machismo.", 
"Instead of settling for a bare bones app to fill the void, the search giant took things one step further. Keep isn't simply just a place to bank whatever random half-thoughts come to mind: Users can construct to-do lists, stash photos, and color code your notes -- all in one well-designed and easy-to-use interface.", 
"This is a note. Loooooooong note. You can't see me very very long long long long long long long long.", 
"This is a note.","The addition of the popular device to the network, plus the rollout of the new instalment plans are the carrierÂ¡Â¦s latest attempts to survive as it struggles to stay afloat. The instalment plans are unlike any other plans offered in the U.S., so offering them is certainly a risky move.");

foreach ($array as $value) {
	$int = rand(1,7);
	if($int==1)
	{
		echo "<div class=\"text\"><div class=\"color\" id=\"red\"></div><div><img src=\"./img/delete.png\"></div><div><img src=\"./img/pencil.jpg\"></div>".$value."</div>";
	}
	else if($int==2)
	{
		echo "<div class=\"text\"><div class=\"color\" id=\"blue\"></div><div><img src=\"./img/delete.png\"></div><div><img src=\"./img/pencil.jpg\"></div>".$value."</div>";
	}
	else if($int==3)
	{
		echo "<div class=\"text\"><div class=\"color\" id=\"green\"></div><div><img src=\"./img/delete.png\"></div><div><img src=\"./img/pencil.jpg\"></div>".$value."</div>";
	}
	else if($int==4)
	{
		echo "<div class=\"text\"><div class=\"color\" id=\"red\"></div><div class=\"color\" id=\"coffee\"></div><div><img src=\"./img/delete.png\"></div><div><img src=\"./img/pencil.jpg\"></div>".$value."</div>";
	}
	else if($int==5)
	{
		echo "<div class=\"text\"><div class=\"color\" id=\"green\"></div><div class=\"color\" id=\"red\"></div><div class=\"color\" id=\"coffee\"></div><div class=\"color\" id=\"blue\"></div><div><img src=\"./img/delete.png\"></div><div><img src=\"./img/pencil.jpg\"></div>".$value."</div>";
	}
	else if($int==6)
	{
		echo "<div class=\"text\"><div class=\"color\" id=\"green\"></div><div class=\"color\" id=\"blue\"></div><div><img src=\"./img/delete.png\"></div><div><img src=\"./img/pencil.jpg\"></div>".$value."</div>";
	}
	else if($int==7)
	{
		echo "<div class=\"text\"><div class=\"color\" id=\"coffee\"></div><div><img src=\"./img/delete.png\"></div><div><img src=\"./img/pencil.jpg\"></div>".$value."</div>";
	}
}
*/
?>

</div>
</div>

</body>
</html>